package com.tianyu.sports.utils;

import org.apache.ibatis.annotations.Select;

import javax.xml.crypto.Data;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;

/**
 * @author Jzen
 * @Title: sports
 * @Package com.tianyu.sports.utils
 * @Description: ${todo}
 * @date 2018/5/28 14:12
 */
public class VipUtil {

    /**
     * 根据当前排名获取价格
     *
     * @param i
     * @return
     */
    public static String getNowUserPrice(int i){
        ++i;
        if(i <= 5000){
            return "99";
        }else if(i <= 10000 ){
            return "199";
        }else if(i <= 20000 ){
            return "299";
        }else if(i <= 40000){
            return "399";
        }else if(i <= 70000){
            return "499";
        }else if(i <= 100000){
            return "599";
        }else {
            return "699";
        }
    }

    /**
     * 获得五位随机数
     *
     * @return
     */
    public static int getRandomByTen(){
        Random rand = new Random();
        return rand.nextInt(90000)+10000;
    }

    /**
     * 获取会员订单信息
     *
     * @param i
     * @return
     */
    public static String getVipNumberOrder(int i){
        int start = 1000000;
        String num = String.valueOf(start+i);
        String substring = "TS"+num.substring(1,num.length());
        return substring;
    }

    /**
     * 获取会员号
     *
     * @param i
     * @return
     */
    public static String getVipNumber(int i){
        if(i <= 5000){
            return "5201-"+getRandomByTen();
        }else if(i <= 10000 ){
            return "5202-"+getRandomByTen();
        }else if(i <= 20000 ){
            return "5203-"+getRandomByTen();
        }else if(i <= 40000){
            return "5204-"+getRandomByTen();
        }else if(i <= 70000){
            return "5205-"+getRandomByTen();
        }else if(i <= 100000){
            return "5206-"+getRandomByTen();
        }else {
            int a = 5206 + i/5000;
            return String.valueOf(a)+"-"+getRandomByTen();
        }
    }

    /**
     * 获取一年后的时间
     *
     * @param date
     * @return
     */
    public static Date getNextTime(Date date){
        Calendar calendar   =   new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(calendar.YEAR, 1);//把日期往后增加一年.整数往后推,负数往前移动
        date=calendar.getTime();   //这个时间就是日期往后推一天的结果
        return date;
    }

    /**
     * 预留排名在条件下跳转
     *
     * @param vipNum
     * @return
     */
    public static int getVipOrder(int vipNum) {

        if(vipNum == 4500){
            return 5000;
        }else if(vipNum == 9500){
            return 10000;
        }else if(vipNum == 19500){
            return 20000;
        }else if(vipNum == 39500){
            return 40000;
        }else if(vipNum == 69500){
            return 70000;
        }else if(vipNum == 99500){
            return 100000;
        }else{
            return vipNum;
        }
    }

    public static void main(String[] args) {
        System.out.println(getVipOrder(4500));
    }
}
